package com.java.boot.admin.service.impl;

import com.java.boot.admin.bean.City;
import com.java.boot.admin.mapper.CityMapper;
import com.java.boot.admin.service.CityService;
import io.micrometer.core.instrument.Counter;
import io.micrometer.core.instrument.MeterRegistry;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author jingjintao
 * @date 2021/7/31 - 0:08
 **/
@Service
public class CityServiceImpl implements CityService {
    @Autowired
    private CityMapper cityMapper;

    private Counter counter;
    public CityServiceImpl(MeterRegistry meterRegistry){
        counter = meterRegistry.counter("mycityservice.getCityById.counter");

    }

    public City getCityById(Long id){
        counter.increment();
        return cityMapper.getById(id);
    }

    public void saveCity(City city) {
        cityMapper.insertCity(city);
    }
}
